﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using OgilvyOne.Model;
using OgilvyOne.BLL;
using System.IO;

public partial class admin_allergy_doctor_info_detail : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.headers.Text = new ColumnBll().LayeridColumnConNaiv("1,179,183,190");

            int columnid = int.Parse(Request.Params["columnid"]);
            if (Request.Params["id"] != null && Request.Params["id"] != "")
            {
                nestle_doctor info = new nestle_doctor();
                DataTable dt = BLLArticleInfo.getDoctor(Request.Params["id"].ToString());
                foreach (DataRow row in dt.Rows)
                {
                    this.id.Value = row["id"].ToString();
                    this.name.Text = row["name"].ToString();
                    this.zhuanjia.Text = row["job"].ToString();
                    this.summary.Text = row["summary"].ToString();
                    this.blog.Text = row["blog"].ToString();
                    this.hospital.Text = row["hospital"].ToString();
                    this.content.Text = row["experience"].ToString();
                    this.indextop.SelectedValue = row["indextop"].ToString();
                    this.sorttop.SelectedValue = row["sorttop"].ToString();
                    this.islive.SelectedValue = row["isonline"].ToString();
                    this.quicklink.SelectedValue = row["quicklink"].ToString();
                    this.blog.Text = row["blog"].ToString();
                    this.objectname.Text = row["objectname"].ToString();
                }
            }

        }

    }


    protected void Sub_click(object sender, EventArgs e)
    {
        int id = 0;
        if (Request.Params["id"] != null && Request.Params["id"] != "")
        {
            id = int.Parse(this.id.Value);
        }
        nestle_doctor info = new nestle_doctor();
        info.Name = this.name.Text.ToString();
        info.Columnid = int.Parse(Request.Params["columnid"]);
        info.Job = this.zhuanjia.Text;
        info.Summary = this.summary.Text;
        info.Blog = this.blog.Text;
        info.Hospital = this.hospital.Text;
        info.Experience = this.content.Text;
        info.Indextop = int.Parse(this.indextop.SelectedValue);
        info.Sorttop = int.Parse(this.sorttop.SelectedValue);
        info.Isonline = int.Parse(this.islive.SelectedValue);
        info.Quicklink = int.Parse(this.quicklink.SelectedValue);
        info.Creattime = DateTime.Now.ToString();
        info.Blog = this.blog.Text;
        info.Objectname = this.objectname.Text;
        info.Onlinetime = this.TextBox1.Text + " " + this.TextBox2.Text + "-" + this.TextBox3.Text;

        //if (this.islive.SelectedValue=="1")
        //{
        //    if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "")
        //    {

        //        Response.Write("<script>alert('请选择日期和时间');location.href='http://www.baidu.com';</script>");
        //    }
        //    else
        //    {
        //    }
        //}
        info.Id = id;
        if (id > 0)
        {
            bool r = BLLArticleInfo.Updatedoctor(info);
        }
        else
        {
            BLLArticleInfo.insertdoctor(info);
        }
        Response.Redirect("doctor_info.aspx?columnid=" + Request.Params["columnid"] + "&layerid=" + Request.Params["layerid"], true);
    }
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        DateTime cur=new DateTime();
        string time=Calendar1.SelectedDate.ToShortDateString();
        time=cur.ToString("m");
        TextBox1.Text = time;
    }
    protected void star_ddl_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBox2.Text = star_ddl.SelectedItem.Text;
    }
    protected void end_ddl_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBox3.Text = end_ddl.SelectedItem.Text;
    }
}

